Skip to content

Conversation

@luin
Copy link
Member

@luin luin commented Jul 25, 2025

This PR added smooth behavior to Quill#scrollRectIntoView(), similar to the native Element#scrollIntoView().

Also upgraded browser-related test suite tools to address #33051

@luin luin force-pushed the zh-animation-scrolling branch from 39b0d30 to ed26d30 Compare July 25, 2025 02:56
@luin luin force-pushed the zh-animation-scrolling branch from b10e57d to 6af4ed5 Compare July 25, 2025 04:46
@luin luin marked this pull request as ready for review July 25, 2025 04:57
@luin luin requested a review from Copilot July 25, 2025 05:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements smooth scrolling animation support for Quill's scrollRectIntoView() and scrollSelectionIntoView() methods, similar to the native Element.scrollIntoView() API. The changes also include upgrades to browser-related test suite tools.

  • Added optional smooth parameter to scrolling methods for animated scrolling behavior
  • Upgraded Playwright and Vitest dependencies to address compatibility issues
  • Enhanced test stability with timing adjustments and improved assertions

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/quill/src/core/utils/scrollRectIntoView.ts Implements smooth scrolling by recording scroll operations and replaying with animation
packages/quill/src/core/quill.ts Adds optional ScrollRectIntoViewOptions parameter to public scrolling methods
packages/quill/test/unit/core/quill.spec.ts Adds test for smooth scrolling functionality and relaxes viewport ratio assertions
packages/quill/test/types/quill.test-d.ts Updates TypeScript type definitions to include smooth scrolling options
packages/quill/package.json Upgrades @playwright/test, @vitest/browser, and vitest dependencies
packages/quill/test/unit/vitest.config.ts Removes deprecated slowHijackESM configuration option
packages/quill/test/fuzz/vitest.config.ts Adds timeout and pool configuration for fuzz tests
packages/quill/test/e2e/utils/index.ts Adds sleep utility function for test timing
packages/quill/test/e2e/list.spec.ts Improves test stability with sleep delays and updated interaction methods
packages/quill/test/e2e/fixtures/index.ts Shortens test fixture text content
Comments suppressed due to low confidence (1)

packages/quill/test/unit/core/quill.spec.ts:1320

  • The relaxed assertion from toBe(1) to toBeGreaterThan(0.9) may mask actual issues with element positioning. Consider using a more precise threshold or adding a comment explaining why exact positioning cannot be expected.
      ).toBeGreaterThan(0.9);

Comment on lines +157 to +161
// Revert all the changes in the scroll position
// and then scroll to the target position with smooth animation
records.forEach(({ element, top, left }) => {
element.scrollBy({ top: -top, left: -left, behavior: 'instant' });
element.scrollBy({ top, left, behavior: 'smooth' });
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smooth scrolling implementation reverts all scroll changes and then re-applies them with animation. This could cause visible flashing or jarring movement, especially with multiple nested scrollable elements. Consider implementing smooth scrolling without the revert-and-replay pattern, or add a check to skip this when no actual scrolling occurred.

Suggested change
// Revert all the changes in the scroll position
// and then scroll to the target position with smooth animation
records.forEach(({ element, top, left }) => {
element.scrollBy({ top: -top, left: -left, behavior: 'instant' });
element.scrollBy({ top, left, behavior: 'smooth' });
// Smoothly scroll to the target position if scrolling is required
records.forEach(({ element, top, left }) => {
if (top !== 0 || left !== 0) {
element.scrollBy({ top, left, behavior: 'smooth' });
}

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +30
await sleep(500); // internal(uiNode): wait for selectionchange to fire

expect(await editorPage.getSelection()).toEqual({
index: 0,
length: 0,
});

await page.keyboard.type('start ');
await sleep(500); // internal(uiNode): wait for selectionchange to fire
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded 500ms sleep delays make tests brittle and slow. Consider using more robust waiting mechanisms like waitFor with condition checks or event listeners instead of arbitrary timeouts.

Copilot uses AI. Check for mistakes.
@luin luin merged commit 2b2e8fd into main Jul 25, 2025
6 checks passed
@luin luin deleted the zh-animation-scrolling branch July 25, 2025 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants